package cn.tedu.ivos.geofence.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceParam;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceQuery;
import cn.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import cn.tedu.ivos.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.spring.web.json.Json;

import java.util.List;

@RestController
@RequestMapping("v1/geofence")
@Slf4j
public class GeofenceController {
    @Autowired
    GeofenceService geofenceService;
    @GetMapping("select")
    public JsonResult selectGeofence (GeofenceQuery geofenceQuery){
        log.debug("电子围栏查询,参数{}",geofenceQuery);
        List<GeofenceVO> list = geofenceService.select(geofenceQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult saveGeofence (GeofenceParam geofenceParam){
        log.debug("电子围栏更新,参数{}",geofenceParam);
        geofenceService.saveGeofence(geofenceParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{geofenceId}")
    public JsonResult deleteGeofence(@PathVariable Long geofenceId){
        log.debug("电子围栏删除,参数{}",geofenceId);
        geofenceService.deleteGeofence(geofenceId);
        return JsonResult.ok();
    }
}
